package org.sfx.apps

import javafx.stage.Stage
import javafx.scene.Group
import javafx.event.EventHandler
import javafx.scene.input.MouseEvent
import javafx.scene.Node
import javafx.scene.control.Label
import javafx.application.Application
import javafx.scene.Scene
import org.sfx.control.TabPane
import org.sfx.control.Tab
import org.sfx.diagnostics.Spy
import org.sfx.rich.Enrich._
import javafx.scene.layout.StackPane
import javafx.scene.layout.HBox
import javafx.scene.layout.Priority
import org.sfx.animation.SfxTimeline
import javafx.util.Duration
import javafx.scene.control.TreeView
import javafx.scene.control.TreeItem

class TabPaneTest extends Application {
  override def start(stage: Stage): Unit = {
    stage.setTitle("The JavaFX Bank")
    // Create the node structure for display
    val rootNode = new Group()
    val scene = new Scene(rootNode, 200, 200)
    Spy.explore(scene)
    val tabPane = new TabPane()
    rootNode.getChildren().addAll(tabPane)
    val tab1 = new Tab("Title 1")
    val stackPane1 = new StackPane()
    tab1.content = stackPane1
    stackPane1.getChildren.add(new Label("Content 1"))
    stackPane1.setStyle("-fx-background-color: blue");
    val tab2 = new Tab("Title 2")
    tab2.content = new Label("Content 2")
    val tab3 = new Tab("Title 3")
    tab3.content = new TreeView[String] {
      this.setRoot(new TreeItem[String]("hello"))
    }
    tabPane.tabs.addAll(tab1, tab2, tab3)
    scene.getStylesheets().addAll("basics.css")
    stage.setScene(scene)
    stage.show()
    val timeline = new SfxTimeline()
    timeline.underlying.setCycleCount(100)
    timeline.addEvent(Duration.seconds(1.0)) {
      rootNode.getChildren().clear()
    }
    timeline.addEvent(Duration.seconds(2.0)) {
      rootNode.getChildren().add(tabPane)
    }
    //timeline.play()
  }
}

object TabPaneTest {
  def main(args: Array[String]): Unit = {
    Application.launch(classOf[TabPaneTest], args)
  }
}
